package com.joysuch.wwyt.bp.entity;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "wwyt_bp_emergency_contingency_plans")
@SQLDelete(sql = "update wwyt_bp_emergency_contingency_plans set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_bp_emergency_contingency_plans set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")

public class BpEmergencyContingencyPlans implements Serializable {

    //预案id
    private Long id;
    //预案名称
    private String name;
    //预案编码
    private String code;
    //适用部门id
    private String useDepartId;
    //预案类型id
    private Long typeId;
    //关联危险源id
    private String hazardId;
    //预案级别
    private Long planLevel;
    //发布日期
    private LocalDate releaseDate;
    //应急成员id
    private String emergencyMember;
    //预案内容
    private String content;
    //预案备注
    private String note;
    //编写人id
    private Long makeUserId;
    //编写部门id
    private Long makeDepartId;
    //附件id
    private String attachmentId;
    //预案状态
    private Integer state;
    //审核人id
    private Long auditUserId;
    //审核时间
    private Date auditTime;
    //审核备注
    private String auditRemaker;
    // 创建人
    private Long createBy;
    // 创建时间
    private java.util.Date createTime;
    // 更新人
    private Long updateBy;
    // 更新时间
    private java.util.Date updateTime;
    // 删除标记
    private String deleteFlag;
    // 组织机构代码
    private String orgCode;
    // 租户
    private Long tenentId;


    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "Id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "NAME")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "CODE")
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Column(name = "USER_DEPART_ID")
    public String getUseDepartId() {
        return useDepartId;
    }

    public void setUseDepartId(String useDepartId) {
        this.useDepartId = useDepartId;
    }

    @Column(name = "TYPE_ID")
    public Long getTypeId() {
        return typeId;
    }

    public void setTypeId(Long typeId) {
        this.typeId = typeId;
    }

    @Column(name = "HAZARD_ID")
    public String getHazardId() {
        return hazardId;
    }

    public void setHazardId(String hazardId) {
        this.hazardId = hazardId;
    }

    @Column(name = "PLAN_LEVEL")
    public Long getPlanLevel() {
        return planLevel;
    }

    public void setPlanLevel(Long planLevel) {
        this.planLevel = planLevel;
    }

    public LocalDate getReleaseDate() {
        return releaseDate;
    }

    public void setReleaseDate(LocalDate releaseDate) {
        this.releaseDate = releaseDate;
    }

    @Column(name = "EMERGENCY_MEMBER")
    public String getEmergencyMember() {
        return emergencyMember;
    }

    public void setEmergencyMember(String emergencyMember) {
        this.emergencyMember = emergencyMember;
    }

    @Column(name = "CONTENT")
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Column(name = "NOTE")
    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    @Column(name = "MAKE_USER_ID")
    public Long getMakeUserId() {
        return makeUserId;
    }

    public void setMakeUserId(Long makeUserId) {
        this.makeUserId = makeUserId;
    }

    @Column(name = "MAKE_DEPART_ID")
    public Long getMakeDepartId() {
        return makeDepartId;
    }

    public void setMakeDepartId(Long makeDepartId) {
        this.makeDepartId = makeDepartId;
    }

    @Column(name = "ATTACHMENT_ID")
    public String getAttachmentId() {
        return attachmentId;
    }

    public void setAttachmentId(String attachmentId) {
        this.attachmentId = attachmentId;
    }

    @Column(name = "STATE")
    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    @Column(name = "AUDIT_USER_ID")
    public Long getAuditUserId() {
        return auditUserId;
    }

    public void setAuditUserId(Long auditUserId) {
        this.auditUserId = auditUserId;
    }

    @Column(name = "AUDIT_TIME")
    public Date getAuditTime() {
        return auditTime;
    }

    public void setAuditTime(Date auditTime) {
        this.auditTime = auditTime;
    }

    @Column(name = "AUDIT_REMARK")
    public String getAuditRemaker() {
        return auditRemaker;
    }

    public void setAuditRemaker(String auditRemaker) {
        this.auditRemaker = auditRemaker;
    }

    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    public Long getCreateBy() {
        return this.createBy;
    }

    public void setCreateBy(Long value) {
        this.createBy = value;
    }

    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    public java.util.Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(java.util.Date value) {
        this.createTime = value;
    }

    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    public Long getUpdateBy() {
        return this.updateBy;
    }

    public void setUpdateBy(Long value) {
        this.updateBy = value;
    }

    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    public java.util.Date getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(java.util.Date value) {
        this.updateTime = value;
    }

    @Column(name = "DELETE_FLAG", length = 2)
    public String getDeleteFlag() {
        return this.deleteFlag;
    }

    public void setDeleteFlag(String value) {
        this.deleteFlag = value;
    }

    @Column(name = "ORG_CODE", length = 100)
    public String getOrgCode() {
        return this.orgCode;
    }

    public void setOrgCode(String value) {
        this.orgCode = value;
    }

    @Column(name = "TENENT_ID")
    public Long getTenentId() {
        return this.tenentId;
    }

    public void setTenentId(Long value) {
        this.tenentId = value;
    }


    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId()).append("name", getName())
                .append("code", getCode()).append("userdeoartId",getUseDepartId()).append("typeId",getTypeId())
                .append("hazardId",getHazardId()).append("planLevel",getPlanLevel()).append("releaseDate",getReleaseDate())
                .append("emergencyMember",getEmergencyMember()).append("content",getContent()).append("note",getNote()).append("makeUserId",getMakeDepartId())
                .append("makeDepartId",getMakeDepartId()).append("attachmentId",getAttachmentId()).append("state",getState()).append("auditUserId",getAuditUserId())
                .append("auditTime",getAuditTime()).append("auditRemark",getAuditRemaker()).append("createBy", getCreateBy())
                .append("createTime", getCreateTime()).append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime()).append("deleteFlag", getDeleteFlag())
                .append("orgCode", getOrgCode()).append("tenentId", getTenentId()).toString();
    }

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof BpEmergencyContingencyPlans == false)
            return false;
        if (this == obj)
            return true;
        BpEmergencyContingencyPlans other = (BpEmergencyContingencyPlans) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
